<script>
import {getPositionList} from "@/api/system.js";
import PositionDialog from "@/views/system/position-manage/components/position-dialog.vue";

export default {
  name: "PositionManage",
  components: {PositionDialog},
  data() {
    return {
      positionData: [],
      positionDialogRef: null
    }
  },
  created() {
    this.getPositionData()
  },
  mounted() {
    this.positionDialogRef = this.$refs.positionDialogRef
  },
  methods: {
    getPositionData() {
      getPositionList().then(res => {
        this.positionData = res
      }).catch(err => {
        console.log(err)
      })
    },
    openPositionDialog() {
      if (this.positionDialogRef) {
        this.positionDialogRef.dialogVisible = true
      }
    }
  }
}
</script>

<template>
  <div class="app-container">
    <el-row>
      <el-col :span="12">
        <el-button type="primary" icon="Plus" @click="openPositionDialog">新增职位</el-button>
        <el-button type="danger" icon="Delete">批量删除职位</el-button>
      </el-col>
    </el-row>
    <el-table :data="positionData" style="width: 100%;margin-top: 20px">
      <el-table-column label="序号" type="index" width="80" align="center" />
      <el-table-column label="职位名称" prop="name" />
      <el-table-column label="描述" prop="description" />
      <el-table-column label="操作" align="center">
        <template v-slot="scope">
          <el-button type="primary" text size="small">编辑</el-button>
          <el-button type="primary" text size="small">选择成员</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
  <position-dialog ref="positionDialogRef" @refreshList="getPositionData"></position-dialog>
</template>

<style scoped>

</style>
